﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IFPRJ.EF.Model;
using IFPRJ.EF.DALayer;

namespace IFPRJ.EF.DALayer.Providers.MySql
{
    public class NewsProvider : INews
    {
        public static IFDBContext dbcontext = new IFDBContext();

        public NewsProvider()
        {
        }

        IFDBContext GetCurrentDBContext()
        {
            if (dbcontext == null)
                return new IFDBContext();
            else
                return dbcontext;

        }


        public bool NewsCreate(News news)
        {
            IFDBContext db = GetCurrentDBContext();
            bool result = false;
            try
            {
                db.Newses.Add(news);
                db.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                throw e;

            }
            return result;
        }

        public bool NewsUpdate(News news)
        {
            return true;
        }

        public bool NewsDelete(News news)
        {
            return true;
        }

        public List<News> NewsLoadAll()
        {
            return new List<News>();
        }

        public News NewsGetSingleByNewsId(int newsid)
        {
            return new News();
        }

        public List<News> NewsGetListByCatoryId(int catoryid)
        {
            return new List<News>();
        }
    }
}
